package eee.xiang.cloud_learning.common.servlet;

import eee.xiang.cloud_learning.bean.entity.TUser;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;

/**
 * @author x-yin
 * @Date 2019/10/21
 */
public class MyServlet extends HttpServlet {

    private List<TUser> list = new ArrayList<TUser>();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    public void destroy() {
        super.destroy();
    }

    @Override
    public void init() throws ServletException {
        System.out.println("----------MyServlet init-------------------");
        Timer timer = new Timer();
        timer.schedule(new mytime(), 6000);
        super.init();
    }

    class mytime extends TimerTask {
        @Override
        public void run() {
            System.out.println("-------------mytime----------------");
            int i = 0;
            do{
                TUser test = new TUser();
                test.setCreateTime(new Date());
                test.setName("尹祥啊尹");
                list.add(test);
                i++;
            }while(i<100000);
        }
    }

}
